package addon.w3.mdx.com;

import java.io.IOException;
import java.util.Vector;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
PRE2						// [ParticleEmitter2]
	long	nbytes;
	struct {
		long	nbytesi;
		long	nbytesikg;		// inclusive bytecount including KGXXs
		ASCII	Name;			(0x50 bytes)
		long	ObjectID;
		long	Parent; 		(0xFFFFFFFF if none)
		long	Flags;	    (bit20)	// +bit26(DontInherit Rotation)
		(KGTR)				// +bit23(Unshaded)	+bit10(Unfogged)
		(KGRT)				// +bit12(XYQuad)	+bit9(LineEmitter)
		(KGSC)				// +bit11(ModelSpace)	+bit8(SortPrimsFarZ)
		float	Speed;
		float	Variation;
		float	Latitidue;
		float	Gravity;
		float	Lifespan;
		float	EmissionRate;
		float	Length;
		float	Width;
		long	FilterMode; 		(0:Blend;1:Additive;2:Modulate;4:AlphaKey)
		long	Rows;
		long 	Columns;
		long	Flag2;			(0:Head;1:Tail;2:Both)
		float	TailLength;
		float	Time;
		struct {			// SegmentColor usually 3 segments
			float	R, G, B; 	// Inverse order from MDL
		} color[numsegments]
		byte	Alpha1, A2, A3;
		float	ScalingX, SY, SZ;
		long	LifeSpanUVAnim1, L2, L3;
		long	DecayUVAnim1, D2, D3;
		long	TailUVAnim1, T2, T3;
		long	TailDecayUVAnim1, TD2, TD3;
		long	TextureID;
		long	Squirt; 		(1:Squirt)
		long	PriorityPlane;
		long	ReplaceableID;
		(KP2S)
		(KP2L)
		(KP2E)
		(KP2V)
		(KP2N)
		(KP2W)
	} particleemitters[npre2s];
 * @author madjk
 */
public class MDXParticleEmitters2 extends MDXParentCOM {
	int length = -1;
	public Vector pemitters = null;
	
	public String getTag() {
		return "PRE2";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		int cntLength = 0;
		pemitters = new Vector();
		while(cntLength < length) {
			MDXParticleEmitter2COM mdcom = new MDXParticleEmitter2COM();
			mdcom.decode(ins);
			pemitters.add(mdcom);
			cntLength += mdcom.nbytesi+mdcom.nbytesikg;
			//System.out.println(" cntLength : "+cntLength);
			//debug( mdcom.toString() );
		}
		//debug( geosets.get( (geosets.size()-1) ).toString() );
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tELEN : "+length);
		if(pemitters != null && pemitters.size() > 0) sb.append("\n\tPEMITTERS[] : "+pemitters.size());
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}